package code.assets
{
	import code.interfaces.ITextSurface;
	
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.geom.Matrix;
	import flash.text.Font;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	import mx.controls.Label;
	import mx.controls.Text;
	import mx.core.BitmapAsset;
	
	public class TextSurface extends MovieClip implements ITextSurface
	{
		private var _text:Label;
		private var _label:TextField;
		private var _id:String;
		private var _tWidth:uint;
		private var _tHeight:uint;
		protected  var Img:Class;
		
		[Embed("assets/ARIAL.TTF", fontName='spArial', mimeType='application/x-font', embedAsCFF = false)]
		public static var ArialFont:Class;
		
		/*[Embed("assets/side01.gif")]
		public static var Img:Class;*/
		
		public function TextSurface()
		{
			super();
			_label = new TextField();
		}
		
		public function get linkID():String
		{
			return this._id;
		}
		
		public function set linkID(linkID:String):void
		{
			this._id = linkID;
		}
		
		public function createLabel(txt:String, bg:uint):void
		{

			/*var bm:BitmapAsset = new Img();
			var matrix:Matrix = new Matrix();
			matrix.a = _tWidth / bm.width;
			matrix.d = _tHeight / bm.height;*/
			
			/*this.graphics.beginBitmapFill(bm.bitmapData, matrix);
			this.graphics.drawRect(0, 0, _tWidth, _tHeight);
			this.graphics.endFill();*/
			
			if(txt != "")
			{
				_label.autoSize = TextFieldAutoSize.LEFT;
				_label.defaultTextFormat = new TextFormat("spArial", 96, 0);
				_label.embedFonts = true;
				_label.scaleX = 2;
				_label.scaleY = 2;
				_label.text = txt;
				_label.rotation = 270;
				_label.y = this.textWidth - 100;
				this.addChild(_label);
			}
			
			this.graphics.beginFill(bg);
			this.graphics.drawRect(0, 0, _tWidth, this.textWidth);
			this.graphics.endFill();
		}
		
		public function get textWidth():uint
		{
			return _label.textWidth * 2 + 200;
		}
		
		override public function set width(val:Number):void
		{
			_tWidth = val;		
		}
		
		override public function set height(val:Number):void
		{	
			//_tHeight = val;
		}
		 
	}
}